/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package util.rm.quml.gemom;

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.util.*;

/*
 * COPYRIGHT DISCLAIMER
 * Synopsis: All the source codes presented in this document are intellectual
 * properties of Queen Mary, University of London.
 * 
 * @year 2010
 * @author Peng Jiang, John Bigham, Jiayi Wu Jinfu Wang------------QMUL
 * @version 1.0 
 */

public class ExcelReader {

    Vector<Vector<String>> vec;
	
    public ExcelReader(){}
        
    public Vector<Vector<String>> getTable(String query){
    	
    	this.vec = new Vector<Vector<String>>();
    	this.vec.add(new Vector<String>());//messages
    	this.vec.add(new Vector<String>());//time
    	
    	Connection c = null;
        Statement stmnt = null;
        try
        {
            Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
            c = DriverManager.getConnection( "jdbc:odbc:sharedData-list", "", "" );
            stmnt = c.createStatement();
            
            ResultSet rs = stmnt.executeQuery( query );
            
            
            while( rs.next() )
            {
                vec.get(0).add(rs.getString(1));
                vec.get(1).add(rs.getString(2));
            }
        }
        catch( Exception e )
        {
            System.err.println( e );
        }
        finally
        {
            try
            {
                stmnt.close();
                c.close();
            }
            catch( Exception e )
            {
                System.err.println( e );
            }
        } 	
    	
    	return vec;
    	}
    
}
